define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'staff/mclock/index' + location.search,
                    add_url: 'staff/mclock/add',
                    edit_url: 'staff/mclock/edit',
                    del_url: 'staff/mclock/del',
                    multi_url: 'staff/mclock/multi',
                    import_url: 'staff/mclock/import',
                    table: 'staff',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                // Search: true,
                // commonSearch: true,
                // searchFormVisible: true,
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id'), operate: false},
                        // {field: 'portraitimage', title: __('Portraitimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'type', title: __('Type'), operate: 'LIKE'},
                        // {field: 'shop_id', title: __('Shop_id')},
                        {field: 'name', title: __('Name'), operate: false},
                        {field: 'c1', title: __('应出勤天数'), operate: false},
                        {field: 'c2', title: __('时间出勤天数'), operate: false},
                        {field: 'c3', title: __('休息天数'), operate: false},
                        {field: 'c4', title: __('迟到次数'), operate: false},
                        {field: 'c5', title: __('早退次数'), operate: false},
                        {field: 'c6', title: __('上班缺卡'), operate: false},
                        {field: 'c7', title: __('下班缺卡'), operate: false},
                        // {field: 'sex', title: __('Sex')},
                        // {field: 'nation', title: __('Nation'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'idcard', title: __('Idcard'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'mobile', title: __('Mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'datebirth', title: __('Datebirth'), operate: 'LIKE'},
                        // {field: 'maritalstatus', title: __('Maritalstatus')},
                        // {field: 'politicaloutlook', title: __('Politicaloutlook'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'education', title: __('Education'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'nativeplace', title: __('Nativeplace'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'location', title: __('Location'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'workingyears', title: __('Workingyears'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'probationperiod', title: __('Probationperiod'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'employmenttime', title: __('Employmenttime'), operate: 'LIKE'},
                        // {field: 'siling', title: __('Siling'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'confirmationtime', title: __('Confirmationtime'), operate: 'LIKE'},
                        // {field: 'staffcode', title: __('Staffcode'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'department', title: __('Department'), operate: 'LIKE'},
                        // {field: 'position', title: __('Position'), operate: 'LIKE'},
                        // {field: 'jobgrade', title: __('Jobgrade'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'rank', title: __('Rank'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'status', title: __('Status')},
                        // {field: 'signingtime', title: __('Signingtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'expirationtime', title: __('Expirationtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'contractimage', title: __('Contractimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        // {field: 'numberofsignings', title: __('Numberofsignings')},
                        // {field: 'p_name', title: __('P_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
